unit UnitCadregiao;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UnitCadModelo, Grids, DBGrids, SMDBGrid, DBCtrls, ComCtrls,
  StdCtrls, Mask, ExtCtrls, Buttons, db, jpeg;

type
  TFormCadRegiao = class(TFormCadModelo)
    Label1: TLabel;
    DBEdit1: TDBEdit;
    Label2: TLabel;
    TabSheet1: TTabSheet;
    DBLookupComboBox1: TDBLookupComboBox;
    DBText1: TDBText;
    SMDBGrid4: TSMDBGrid;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btOKClick(Sender: TObject);
    procedure btCancelarClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormCadRegiao: TFormCadRegiao;

implementation

uses UnitRegiao;

{$R *.dfm}

procedure TFormCadRegiao.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  with FormRegiao do
  begin
    if qryDados.State in [dsInsert,dsEdit] then
      qryDados.Post;
    if qryFranGrupo.State in [dsInsert,dsEdit] then
      qryFranGrupo.Post;
  end;
  FormCadRegiao := nil;
end;

procedure TFormCadRegiao.btOKClick(Sender: TObject);
begin
  inherited;
  with FormRegiao do
  begin
    if qryDados.State in [dsInsert,dsEdit] then
      qryDados.Post;
    if qryFranGrupo.State in [dsInsert,dsEdit] then
      qryFranGrupo.Post;
  end;
end;

procedure TFormCadRegiao.btCancelarClick(Sender: TObject);
begin
  inherited;
  with FormRegiao do
  begin
    if qryFranGrupo.State in [dsInsert,dsEdit] then
      qryFranGrupo.Cancel;
    if qryDados.State in [dsInsert,dsEdit] then
      qryDados.Cancel;
  end;
end;

end.
